package com.adcc.loadsheet.billing.vo.chargerule;

import com.adcc.loadsheet.billing.entity.chargerule.BillingRuleEntity;
import com.adcc.loadsheet.billing.entity.chargerule.BillingLadderEntity;
import com.adcc.loadsheet.billing.vo.BasisVO;
import com.google.common.collect.Lists;

import java.util.Date;
import java.util.List;

/**
 * 计费规则表实体VO
 * Created by zhaoml on 2020/4/7.
 */
public class BillingRuleEntityVO extends BasisVO<BillingRuleEntity> {
    private Integer billingRuleId;   //主键ID
    private String ruleAbbrev;  //规则简称
    private String ruleFullname; //规则全称
    private int ruleRate;   //重发率
    private String remark;   //备注
    private Date createAt;  //创建时间
    private String createUser;   //创建人
    private Date updateAt;   //更新时间
    private String updateUser;  //更新人

    private List<BillingLadderEntityVO> billingLadderEntityVOList;  //阶梯计数

    private Boolean checked;    //是否被选中（合同用户中使用）

    @Override
    public BillingRuleEntity toEntity() {
        BillingRuleEntity billingRuleEntity = new BillingRuleEntity();
        billingRuleEntity.setBillingRuleId(this.billingRuleId);
        billingRuleEntity.setRuleAbbrev(this.ruleAbbrev);
        billingRuleEntity.setRuleFullname(this.ruleFullname);
        billingRuleEntity.setRuleRate(this.ruleRate);
        billingRuleEntity.setRemark(this.remark);
        billingRuleEntity.setCreateAt(this.createAt);
        billingRuleEntity.setCreateUser(this.createUser);
        billingRuleEntity.setUpdateAt(this.updateAt);
        billingRuleEntity.setUpdateUser(this.updateUser);
        return billingRuleEntity;
    }

    public BillingRuleEntityVO(){}
    public BillingRuleEntityVO(
            BillingRuleEntity billingRuleEntity, List<BillingLadderEntity> billingLadderEntityList){
        this.setBillingRuleId(billingRuleEntity.getBillingRuleId());
        this.setRuleAbbrev(billingRuleEntity.getRuleAbbrev());
        this.setRuleFullname(billingRuleEntity.getRuleFullname());
        this.setRuleRate(billingRuleEntity.getRuleRate());
        this.setRemark(billingRuleEntity.getRemark());
        this.setCreateAt(billingRuleEntity.getCreateAt());
        this.setCreateUser(billingRuleEntity.getCreateUser());
        this.setUpdateAt(billingRuleEntity.getUpdateAt());
        this.setUpdateUser(billingRuleEntity.getUpdateUser());


        //阶梯计价
        List<BillingLadderEntityVO> billingLadderEntityVOs = Lists.newArrayList();
        BillingLadderEntityVO billingLadderEntityVO = null;
        Integer orderNumber = 1;
        for(BillingLadderEntity billingLadderEntity : billingLadderEntityList){
            billingLadderEntityVO = billingLadderEntity.toVO();
            billingLadderEntityVO.setOrderNumber(orderNumber++); //页面显示的序号（递增）
            billingLadderEntityVOs.add(billingLadderEntityVO);
        }
        this.setBillingLadderEntityVOList(billingLadderEntityVOs);
    }

    @Override
    public String toJSON() {
        return null;
    }

    public Integer getBillingRuleId() {
        return billingRuleId;
    }

    public void setBillingRuleId(Integer billingRuleId) {
        this.billingRuleId = billingRuleId;
    }

    public String getRuleAbbrev() {
        return ruleAbbrev;
    }

    public void setRuleAbbrev(String ruleAbbrev) {
        this.ruleAbbrev = ruleAbbrev;
    }

    public String getRuleFullname() {
        return ruleFullname;
    }

    public void setRuleFullname(String ruleFullname) {
        this.ruleFullname = ruleFullname;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Date getCreateAt() {
        return createAt;
    }

    public void setCreateAt(Date createAt) {
        this.createAt = createAt;
    }

    public String getCreateUser() {
        return createUser;
    }

    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }

    public Date getUpdateAt() {
        return updateAt;
    }

    public void setUpdateAt(Date updateAt) {
        this.updateAt = updateAt;
    }

    public String getUpdateUser() {
        return updateUser;
    }

    public void setUpdateUser(String updateUser) {
        this.updateUser = updateUser;
    }

    public List<BillingLadderEntityVO> getBillingLadderEntityVOList() {
        return billingLadderEntityVOList;
    }

    public void setBillingLadderEntityVOList(List<BillingLadderEntityVO> billingLadderEntityVOList) {
        this.billingLadderEntityVOList = billingLadderEntityVOList;
    }

    public Boolean getChecked() {
        return checked;
    }

    public void setChecked(Boolean checked) {
        this.checked = checked;
    }

    public int getRuleRate() {
        return ruleRate;
    }

    public void setRuleRate(int ruleRate) {
        this.ruleRate = ruleRate;
    }
}